package com.alibaba.aliper.client;


import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;

import com.alibaba.aliper.client.model.AliperClientModel;
import com.alibaba.aliper.client.view.AliperWindow;

public class AliperClient{
	
	@Option(
			name = "-s", 
			usage = "serverURL,the hessian service address.", 
			metaVar="serverURL",
			required = false
	)
	private String serverUrl = null;
	
	public static void main(String[] args) {
		AliperClient client = new AliperClient();
		CmdLineParser cmdLineParser = new CmdLineParser(client);
		try {
			cmdLineParser.parseArgument(args);
		} catch (CmdLineException e) {
			System.err.println(e.getMessage());
			System.out.println("Usage:");
			cmdLineParser.printUsage(System.out);
			System.exit(0);
		}
		client.start();
	}
	
	public AliperClient(){
		this.clientModel.setView(this.clientView);
		this.clientView.setModel(this.clientModel);
	}
	
	private AliperClientModel clientModel = new AliperClientModel();
	private AliperWindow clientView = new AliperWindow();

	public void start() {
		this.clientModel.setServiceUrl(this.serverUrl);
	    this.clientView.setVisible(true);
	}
}
